package app.kotlin_1.utils

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings
import app.kotlin_1.BuildConfig

/**
 * Created by 刘智强 on 2017/10/12.
 */
 object  AppUtils{


    public  fun goAppSettingIntent(context:Context?){
        var  intent=Intent()
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

        when {
            Build.VERSION.SDK_INT>=9 -> {
                intent.action = "android.settings.APPLICATION_DETAILS_SETTINGS"
                intent.data = Uri.fromParts("package",context?.packageName,null)
            }
            Build.VERSION.SDK_INT<=8 -> {
                intent.action = Intent.ACTION_VIEW;
                intent.setClassName("com.android.settings","com.android.setting.InstalledAppDetails")
                intent.putExtra("com.android.settings.ApplicationPkgName",context?.packageName)
            }
            Build.VERSION.SDK_INT==11 -> {
                intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
           var uri = Uri.fromParts("package", context?.packageName, null)
                intent.data = uri


            }
        }
        context?.startActivity(intent)

    }
}